<?php
/**
 * Every page is accessed through this page.  This allows for the directory 
 * structure to remain as it is without having to move things such as images 
 * into each specific folder.  Every module is able to access from the root 
 * directory.
 * 
 * All Pages Created by Soynuts
 * http://unbuinc.net
 * 
 * You are free to modify the pages as you see fit.     
 */

define("ROOTDIR", dirname(__FILE__)); // Global Constant of root directory

// ############################# INCLUDES #####################################
require_once(ROOTDIR."/config/class.Config.php");
require_once(ROOTDIR."/include/database/class.Database.php");
require_once(ROOTDIR."/include/php4functions.php");
// ############################################################################

// ############################### INIT #######################################
$db = new Database(); // Just about every page makes a database call
$config = new Config(); // All configuration variables are contained in this object
$version = "v3.2";
// ############################################################################

// Page to access
if(isset($_GET['page'])) {
	$page = $_GET['page']; // Get page name from
}
else {
	$page = "banlist";
}

$ajax = 0;
if(isset($_GET['ajax'])) {
	$ajax = $_GET['ajax']; // Get ajax value
}

$esScript = 0;
if(isset($_GET['es'])) {
	$esScript = $_GET['es']; // Get es value
}

$adminPage = 0;
if(isset($_GET['adminPage'])) {
  $adminPage = $_GET['adminPage'];
}

// For non-AJAX pages
if($ajax == 1) {
  // We do not need or want the header or footer for ajax pages as they are
  // used to generate XML
  require_once(ROOTDIR."/ajax/".$page.".php");
} else if($esScript == 1) {
  // We are executing a page from an eventscript
  // The header and footer is not needed
  require_once(ROOTDIR."/es/".$page.".php");
} else {
  
  // ############################# HEADER #####################################
  require_once(ROOTDIR."/include/header.php");
  // ##########################################################################
  
  if($adminPage == 1) {
    // We are loading admin pages
    require_once(ROOTDIR."/admin/".$page.".php");
  } else {
    require_once(ROOTDIR."/".$page.".php");
  }
  
  // ############################# FOOTER #####################################
  require_once(ROOTDIR."/include/footer.php");
  // ##########################################################################
}
?>
